<template>
  <div class="homePage">
    <div class="home--title">
      <span class="gradient-text">{{ projectInfo.name }}</span>
      <div style="display: flex;justify-content: flex-end">
        <user-select color="#333333" style="position: absolute;" />
      </div>
    </div>

    <div class="home--box">
      <el-row :gutter="20" type="flex" justify="start" class="custom-row" style="padding: 0 20px">
        <el-col v-for="(item, index) in homeRoutes" :key="index" class="box--col"
          style="margin-bottom: 30px; display: flex" :xs="24" :sm="12" :md="8" :lg="6">
          <div class="card-wrapper" style="width: 100%">
            <el-card shadow="hover" class="item" :style="{ height: cardHeight }">
              <div class="home--container" @click="$router.push(item.path)">
                <div class="image-wrapper">
                  <img :src="require(`@/assets/image/${item.icon}.png`)" />
                </div>
                <div class="menu-title">{{ item.name }}</div>
              </div>
            </el-card>
          </div>
        </el-col>
      </el-row>
    </div>

  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { Getter } from "vuex-class";
import { homeRoutes } from "@/router/homeRouter";
import UserSelect from "@/components/UserSelect.vue";
@Component({
  components: {
    UserSelect
  }
})
export default class HomePage extends Vue {
  private homeRoutes = homeRoutes;
  cardHeight = "190px";
  @Getter('projectInfo') private projectInfo: any;
  @Getter('routers') private routers!: any;
}
</script>
<style lang="scss" scoped>
.homePage {
  width: 100%;
  height: 100%;
  padding: 20px 0;
  overflow: hidden;
  background: url("../../assets/image/home-bg.png") no-repeat;
  background-size: 100% 100%;
  box-sizing: border-box;

  .home--title {
    width: 1300px;
    text-align: center;
    color: #006400;
    font-family: sans - serif;
    font-size: 55px;
    font-weight: bold;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 50px;


  }

  .home--box {
    display: flex;
    justify-content: center;

    ::v-deep .el-row {
      flex-wrap: wrap; // 强制换行
      max-width: 1440px; // 根据实际需求调整
      margin: 0 auto;

      ::v-deep .custom-row {
        max-width: 1200px;
        margin: 0 auto;
        width: 100%;
        flex-wrap: wrap;
        align-content: flex-start;
        /* 关键：顶部对齐 */

        .el-col {
          padding: 10px !important;
          display: flex;
          justify-content: center;
          flex: 0 0 calc(25% - 10px);
          /* 精确计算宽度 */
          max-width: calc(25% - 10px);
          margin: 0 5px 30px;
          /* 均匀分布间距 */
          height: 200px;

          /* 固定高度 */
          .card-wrapper {
            width: 100%;
            padding: 5px;
            transition: all 0.3s ease;

            &:hover {
              transform: translateY(-5px);

              .item {
                box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
              }
            }
          }
        }
      }

      .el-col {
        padding: 0 10px !important; // 替代原有margin
        min-width: 240px; // 最小宽度防止挤压

        .card-wrapper {
          padding: 5px; // 替代位移补偿
        }
      }
    }

    .item {
      overflow: visible;
      /* 确保动画不裁剪 */
      height: 100%;
      transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
      backface-visibility: hidden; // 防止抖动

      &:hover {
        transform: translateY(-5px) scale(1.02);
        z-index: 2;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2) !important;
      }
    }

    .box--col {
      margin-bottom: 20px;
      transition: transform 0.3s ease; // 添加卡片整体过渡

      .card-wrapper {
        height: calc(100% + 5px); // 预留位移空间
        padding-bottom: 5px; // 补偿位移
      }

      &:hover {
        transform: translateY(-5px); // 悬停时卡片上移
      }

      .item {
        transition: all 0.3s ease;
        position: relative;
        top: 0;

        &:hover {
          top: -5px; // 用相对定位替代translate
          box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.15);
        }
      }

      .home--container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 16px;
        padding: 20px 0;


        .image-wrapper {
          transform: scale(1);
          transition: transform 0.3s ease;

          &:hover {
            transform: scale(1.05); // 只做缩放动画
          }
        }

        .image-wrapper {
          position: relative;
          width: 100px;
          height: 100px;
          transition: all 0.3s ease;

          img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            transition: all 0.3s ease;
            filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
          }

          &::after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background: rgba(91, 227, 159, 0.1);
            transform: scale(0.9);
            transition: all 0.3s ease;
          }
        }

        .menu-title {
          width: 100%;
          text-align: center;
          font-size: 18px; // 初始字号调大
          font-weight: bold;
          color: #333;
          transition: all 0.3s ease;
          text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        &:hover {
          .menu-title {
            font-size: 22px; // 悬停时字号变大
            color: #5be39f; // 文字颜色变化
          }

          .image-wrapper {
            transform: scale(1.1); // 图片容器放大

            img {
              transform: rotate(5deg) scale(1.1); // 图片微旋转+放大
              filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
            }

            &::after {
              transform: scale(1.1);
              background: rgba(91, 227, 159, 0.2);
            }
          }
        }
      }
    }
  }
}

.gradient-text {
  display: inline-block;
  background: linear-gradient(90deg,
      #007bff 0%, // 左侧蓝色
      #00ff88 50%, // 中间过渡色
      #006400 100% // 右侧绿色
    );
  user-select: none; // 禁止文字选择
  -webkit-user-select: none; // Safari兼容
  -moz-user-select: none; // Firefox兼容
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: bold;
  letter-spacing: 1px;

  // 添加动画效果（可选）
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  /* 添加文字阴影增强立体感 */
  animation: gradientShift 3s ease infinite;
  filter:
    drop-shadow(0 2px 4px rgba(0, 123, 255, 0.2)) // 蓝色投影
    drop-shadow(0 2px 8px rgba(40, 167, 69, 0.2)); // 绿色投影
  text-rendering: optimizeLegibility; // 优化渲染
  -webkit-font-smoothing: subpixel-antialiased; // Mac字体抗锯齿

  // 添加材质效果（可选）
  position: relative;

  &::after {
    content: "内蒙古自治区自然灾害综合风险普查成果应用系统";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('');
    opacity: 0.15;
    mix-blend-mode: overlay;
  }
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}


/* 响应式适配 */
@media (max-width: 1200px) {
  .home--box ::v-deep .el-col {
    flex: 0 0 25%;
    max-width: 25%;
  }
}

@media (max-width: 992px) {
  .home--box {
    ::v-deep .custom-row {
      max-width: 900px;
    }

    ::v-deep .el-col {
      flex: 0 0 33.33%;
      max-width: 33.33%;
    }
  }
}

@media (max-width: 768px) {
  .home--box {
    ::v-deep .custom-row {
      max-width: 600px;
    }

    ::v-deep .el-col {
      flex: 0 0 50%;
      max-width: 50%;
    }
  }
}
</style>
